package com.labot.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.AccessType;
import org.hibernate.search.annotations.Field;

import com.labot.types.MailType;

/**
 * @author Ing. Enrique Barbeito
 * 
 */
@Entity
@Table(name = "app_mailtemplate")
@AccessType("field")
@XmlRootElement
public class MailTemplate extends BaseObject  implements Serializable {
    private static final long serialVersionUID = 3832626162173359411L;

	@Field
	@Column(nullable = false, length = 50, unique = true)
    @Enumerated(EnumType.STRING)
    private MailType name;
    
    @Field
    private String subject_en;
    
    @Field
    private String body_en;
    
    @Field
    private String subject_es;
    
    @Field
    private String body_es;
    
    /**
     * Default constructor - creates a new instance with no values set.
     */
    public MailTemplate() {
    	
    }

    public MailTemplate(MailType name) {
    	this.name = name;
    }

	public MailType getName() {
		return name;
	}


	public void setName(MailType name) {
		this.name = name;
	}


	public String getSubject_en() {
		return subject_en;
	}


	public void setSubject_en(String subject_en) {
		this.subject_en = subject_en;
	}


	public String getBody_en() {
		return body_en;
	}


	public void setBody_en(String body_en) {
		this.body_en = body_en;
	}


	public String getSubject_es() {
		return subject_es;
	}


	public void setSubject_es(String subject_es) {
		this.subject_es = subject_es;
	}


	public String getBody_es() {
		return body_es;
	}


	public void setBody_es(String body_es) {
		this.body_es = body_es;
	}


	/**
     * {@inheritDoc}
     */
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof MailTemplate)) {
            return false;
        }

        final MailTemplate config = (MailTemplate) o;

        return (config.getName().equals(this.getName()));

    }

    /**
     * {@inheritDoc}
     */
    public int hashCode() {
        return (id != null ? id.hashCode() : 0);
    }

    /**
     * {@inheritDoc}
     */
    public String toString() {
        ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE)
        		.append("id", this.getId())
                .append("name", this.getName())
                .append("subject", this.getSubject_en());
        return sb.toString();
    }
}
